/**
 * get the data from server and handle it
 */
function EDAO(clz) {
    this.clz = clz;
}

EDAO.prototype = {
    create: function (obj) {
        $http({
            "method": "post",
            "url": "localhost:28080/litejs-server",
            "data": {
                "clz": this.clz,
                "act": "create",
                "obj": obj
            },
            "success": function (data) {
                // deal with the data
                alert(data);
            },
            "Error": function (text) {
                alert(text);
            },
            "async": false
        });
    },
    update: function (obj) {
        $http({
            "method": "post",
            "url": "localhost:28080/litejs-server",
            "data": {
                "clz": this.clz,
                "act": "update",
                "obj": obj
            },
            "success": function (data) {
                alert(data);
            },
            "Error": function (text) {
                alert(text);
            },
            "async": false
        });
    },
    read: function (id) {
        $http({
            "method": "get",
            "url": "localhost:28080/litejs-server",
            "data": {
                "id": id,
                "act": "read",
                "clz": this.clz
            },
            "success": function (data) {
                alert(data);
            },
            "Error": function (text) {
                alert(text);
            },
            "async": false
        });
    },
    delete: function (id) {
        $http({
            "method": "post",
            "url": "localhost:28080/litejs-server",
            "data": {
                "clz": this.clz,
                "act": "delete",
                "id": id
            },
            "success": function (data) {
                alert(data);
            },
            "Error": function (text) {
                alert(text);
            },
            "async": false
        });
    }
};
